home *** CD-ROM | disk | FTP | other *** search
- Path: news.connect.net!usenet
- From: tomw@intelligraphics.com
- Newsgroups: comp.lang.c++,comp.os.msdos.programmer
- Subject: Re: Function Pointers In C++
- Date: 10 Feb 1996 16:59:12 GMT
- Organization: Connection Technologies
- Message-ID: <4fiit0$oqp@dallas1.connect.net>
- References: <yAkGxc9nXE/T083yn@mbnet.mb.ca>
- Reply-To: tomw@intelligraphics.com
- NNTP-Posting-Host: igxtest.intelligraphics.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <yAkGxc9nXE/T083yn@mbnet.mb.ca>, natewild@mbnet.mb.ca (Nathan T. Wild) writes:
- >
- >I have a class which contains function pointers. The actual code for these
- >functions is dynamically loaded from disk at run time. I seem to be having
- >troubles setting these pointers??? I have done this before in C, but I
- >guess C is a little more forgiving than C++ with respect to type checking.
- >The declaration for my class is as follows (byte is a typedef to unsigned
- >char):
-
- The solution I used "fools" the compiler by using an anonymous union. E.g.,
-
- union {
- byte (*pfn) (void);
- void (*vpfn) (void);
- };
-
- vpfn = GetFunctionPtr (1);
- Init = pfn;
-
- Hope this helps.
-
- +---------------------------------------------------------------------------+
- + Tom Wheeler | Member NRA, NMRA +
- + tomw@intelligraphics.com | OS/2 user, C++ programmer +
- + ------------------------------------------------------------------------- +
- + Use or reproduction of this document or the author's email address for +
- + commercial purposes without the author's permission is prohibited. +
- +---------------------------------------------------------------------------+
-
-